﻿@{var seesionVar = Session["SELECTED-USER"] as SecurityApi.DataAccess.EnterpriseUser;}
@{var currentApplication = Session["SELECTED-APPLICATION"] as SecurityApi.Model.Application; }
@{
    Layout = "~/Views/Shared/_LayoutManageUser.cshtml";
}

<h3>USER:  @seesionVar.UserName</h3>

<table>
    <tr>
        <td>Available Roles</td>
        <td>Assigned Roles</td>
    </tr>
    <tr>
        <td>
            @(Html.Kendo().Grid<SecurityApi.DataAccess.Role>()
                .Name("AvailableRolesGrid")
                .HtmlAttributes(new { style = "height:300px;width=250px;" })
                .Columns(columns =>
                {
                    //If your grid is ajax bound. You should also define a ClientTemplate for all template columns:
                    columns.Template(@<text>
                                    @Html.ActionLink("Add", "AddUserRole", "UserRole", new { roleId = @item.RoleId})  
                                    </text>)
                                .ClientTemplate("<a href='" + Url.Content("~/UserRole/AddUserRole/?") + "roleId= #= RoleId #'" + ">Add</a>") //always use Url.Content to get the correct relative path
                                .Title("View").Width(70);
                    columns.Bound(c => c.RoleName);
                })
                .Pageable()
                .Sortable()
                .Selectable()
                .Filterable()
                .Scrollable()
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(50)
                    .Read(read => read.Action("AjaxGetAvailableRoles", "UserRole", new {userId=@seesionVar.UserId,applicationId=@currentApplication.ApplicationId}))
                )
            )
        </td>

        <td>
@(Html.Kendo().Grid<SecurityApi.DataAccess.Role>()
    .Name("AssignedRolesGrid")
    .HtmlAttributes(new { style = "height:300px;width=250px;" })
    .Columns(columns =>
    {
        //If your grid is ajax bound. You should also define a ClientTemplate for all template columns:
        columns.Template(@<text>
                        @Html.ActionLink("Remove", "RemoveUserRole", "UserRole", new { roleId = @item.RoleId})  
                        </text>)
                    .ClientTemplate("<a href='" + Url.Content("~/UserRole/RemoveUserRole/?") + "roleId= #= RoleId #'" + ">Remove</a>") //always use Url.Content to get the correct relative path
                    .Title("View").Width(70);
                    columns.Bound(c => c.RoleName);
    })
    .Pageable()
    .Sortable()
    .Selectable()
    .Filterable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .Read(read => read.Action("AjaxGetAssignedRoles", "UserRole", new {userId=@seesionVar.UserId,applicationId=@currentApplication.ApplicationId}))
    )
)

        </td>
    </tr>
</table>

